package com.forum.service.Impl;

import com.forum.dao.AdminDaoMapper;
import com.forum.dao.MessageDaoMapper;
import com.forum.dao.UserDaoMapper;
import com.forum.pojo.Admin;
import com.forum.pojo.Message;
import com.forum.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("AdminService")
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminDaoMapper adminDaoMapper;
    @Autowired
    private MessageDaoMapper messageDaoMapper;

    public AdminDaoMapper getAdminDaoMapper() {
        return adminDaoMapper;
    }

    public void setAdminDaoMapper(AdminDaoMapper adminDaoMapper) {
        this.adminDaoMapper = adminDaoMapper;
    }

    @Override
    public boolean login(Admin admin) {
        if(adminDaoMapper.findAdmin(admin)!=null){
            System.out.println("1");
            return true;
        }
        System.out.println("2");
        return false;
    }

    @Override
    public List<Message> findUnAudit() {
        Message message =new Message();
        message.setAuditSatus("未审核");
        return messageDaoMapper.findMessage(message);
    }

    @Override
    public int audit(String messageID,String status) {
        Message message = new Message();
        message.setMessageID(messageID);
        message.setAuditSatus(status);
        messageDaoMapper.updateAudit(message);
        return 0;
    }

    @Override
    public int deleteMessage(String messageID) {
        messageDaoMapper.deleteMessage(messageID);
        return 0;
    }
}
